#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'Lucas Meneghel Rodrigues <lmr@redhat.com>'

import os
import sys
import logging


if sys.version_info[:2] == (2, 6):
    import unittest2 as unittest
else:
    import unittest

logger = logging.getLogger(__name__)


def test_suite():
    suite = unittest.TestSuite()
    loader = unittest.TestLoader()
    selftests_dir = os.path.dirname(os.path.abspath(__file__))
    basedir = os.path.dirname(selftests_dir)
    for section in (['functional', 'unit', 'doc']):
        suite.addTests(loader.discover(start_dir=os.path.join(selftests_dir, section),
                                       top_level_dir=basedir))
    return suite


if __name__ == '__main__':
    runner = unittest.TextTestRunner()
    result = runner.run(test_suite())
    if result.failures or result.errors:
        sys.exit(1)
